<!DOCTYPE html>
<!-- saved from url=(0038)https://sns.tianqiapi.com/sns/userinfo -->
<html lang="zh-cn"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    
    <meta name="author" content="聊天室系统配置服务 QQ: 445899710 微信: hype522147">
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">
    <title>微聊</title>
    <link rel="icon" href="https://sns.tianqiapi.com/favicon.ico" type="image/x-icon">
    <link rel="stylesheet" href="./个人信息_files/weui.min.css">
    <link rel="stylesheet" href="./个人信息_files/layer.css">
    <link rel="stylesheet" href="./个人信息_files/app.css">
        <style>
        body {
            background: #ededed;
        }
    </style>
<link rel="stylesheet" href="./个人信息_files/layer(1).css" id="layuicss-layer"></head>
<body>
    <!--navbar-->
    <div class="navbar">个人信息<img class="btnleft" src="./个人信息_files/left.png"></div>
    <div class="line40"></div>

    <div class="weui-cells">
        <div class="weui-cell weui-cell_access" onclick="uploadImg()">
            <div class="weui-cell__bd">
                <p>头像</p>
            </div>
            <div class="weui-cell__ft"><img id="avatar" class="weui-media-box__thumb" src="./个人信息_files/006WzJNkly8fxc42sjxisj30u00u0jub.jpg" style="width: 60px;"></div>
        </div>
        <div class="weui-cell weui-cell_access" onclick="editmobile()">
            <div class="weui-cell__bd">
                <p>手机号</p>
            </div>
            <div class="weui-cell__ft" id="mobile"></div>
        </div>
        <div class="weui-cell weui-cell_access" onclick="editnickname()">
            <div class="weui-cell__bd">
                <p>昵称</p>
            </div>
            <div class="weui-cell__ft" id="nickname">刘先生</div>
        </div>
        <div class="weui-cell weui-cell_access" onclick="editcode()">
            <div class="weui-cell__bd">
                <p>账号</p>
            </div>
            <div class="weui-cell__ft" id="uuid"></div>
        </div>
        <div class="weui-cell weui-cell_access" onclick="selectgender()">
            <div class="weui-cell__bd">
                <p>性别</p>
            </div>
            <div class="weui-cell__ft" id="sex">
                男            </div>
        </div>
        <div class="weui-cell weui-cell_access" onclick="editqm()">
            <div class="weui-cell__bd">
                <p>签名</p>
            </div>
            <div class="weui-cell__ft" id="intro">未设置</div>
        </div>
    </div>


    <!--avatar-->
    <div style="display: none">
        <form id="demoForm" method="POST" enctype="multipart/form-data">
            <input type="file" id="uploadimg" name="file" accept="image/*" onchange="uploadDo()">
        </form>
    </div>
    <!--修改-->
    <div>
        <div class="weui-mask" id="iostask" style="opacity: 1; display: none;"></div>
        <div class="weui-actionsheet" id="iosActionsheet">
            <div class="weui-actionsheet__title">
                <p class="weui-actionsheet__title-text">
                    <input id="inputtext" class="weui-input" type="text" placeholder="" style="text-align: center">
                </p>
            </div>
            <div class="weui-actionsheet__menu">
                <div class="weui-actionsheet__cell" style="color: #07C160;" onclick="saveedit()">保存修改</div>
            </div>
            <div class="weui-actionsheet__action">
                <div class="weui-actionsheet__cell" onclick="hideActionSheet()">取消</div>
            </div>
        </div>
    </div>
<script type="text/javascript" src="./个人信息_files/jquery.min.js"></script>
<script type="text/javascript" src="./个人信息_files/layer.js"></script>
<script type="text/javascript" src="./个人信息_files/app.js"></script>
    <script src="./个人信息_files/weui.min.js"></script>
    <script type="text/javascript">
        function selectgender() {
            weui.picker([{
                label: '男',
                value: 1
            }, {
                label: '女',
                value: 2
            }], {
                onChange: function (result) {
                },
                onConfirm: function (result) {
                    console.log(result[0].value);
                    ctype = 'sex'
                    $.ajax({
                        type: 'POST',
                        url: '/sns/usersave',
                        data: 'ctype=' + ctype + '&inputtext=' + result[0].value,
                        dataType: 'JSON',
                        error: function () {
                            layer.alert('网络错误');
                        },
                        success: function (res) {
                            if (res.errcode == 0) {
                                layer.msg(res.errmsg);
                                $('#' + ctype).text(result[0].label)
                                hideActionSheet()
                            } else {
                                layer.msg(res.errmsg);
                            }
                        }
                    });
                },
                title: '性别选择'
            });
        }
        var ctype = '';
        function editmobile() {
            ctype = 'mobile'
            $('#inputtext').val('');
            $('#inputtext').attr({'placeholder': '请输入新的手机号'});
            showActionSheet()
        }
        /*微聊号*/
        function editcode() {
            ctype = 'uuid'
            $('#inputtext').val('');
            $('#inputtext').attr({'placeholder': '请输入新的账号'});
            showActionSheet()
        }
        /*签名*/
        function editqm() {
            ctype = 'intro'
            $('#inputtext').val('');
            $('#inputtext').attr('placeholder', '请输入新的签名');
            showActionSheet()
        }
        function editnickname() {
            ctype = 'nickname'
            $('#inputtext').val('');
            $('#inputtext').attr('placeholder', '请输入新昵称');
            showActionSheet()
        }

        function uploadImg() {
            document.getElementById('uploadimg').click();
        }
        function uploadDo() {
            var layer_index = layer.load(0, {shade: 0.3});
            // 获取 policy 和 secret
            $.getJSON('/index/policyChat', function (data) {
                console.log('上传中');
                var uploadData = new FormData($('#demoForm')[0]);
                uploadData.append('policy', data.policy);
                uploadData.append('authorization', data.authorization);
                $.ajax({
                    url: 'https://v0.api.upyun.com/chatcdn',
                    type: 'POST',
                    data: uploadData,
                    dataType: 'JSON',
                    cache: false,
                    processData: false,
                    contentType: false,
                }).done(function (data, textStatus) {
                    console.log(data.url);
                    layer.close(layer_index);
                    $.ajax({
                        type: 'POST',
                        url: '/sns/usersave',
                        data: 'avatar=' + 'http://chatcdn.tianqiapi.com' + data.url,
                        dataType: 'JSON',
                        error: function () {
                            layer.alert('网络错误');
                        },
                        success: function (res) {
                            if (res.errcode == 0) {
                                layer.msg(res.errmsg);
                                $('#avatar').attr('src', 'http://chatcdn.tianqiapi.com' + data.url + '!face');
                            } else {
                                layer.msg(res.errmsg);
                            }
                        }
                    });

                }).fail(function (res, textStatus, error) {
                    layer.close(layer_index);
                });
            });
        }

        function saveedit() {
            var inputtext = $('#inputtext').val()
            if (inputtext == '') {
                layer.msg('没有任何修改')
                return
            }
            $.ajax({
                type: 'POST',
                url: '/sns/usersave',
                data: 'ctype=' + ctype + '&inputtext=' + inputtext,
                dataType: 'JSON',
                error: function () {
                    layer.alert('网络错误');
                },
                success: function (res) {
                    if (res.errcode == 0) {
                        layer.msg(res.errmsg);
                        $('#' + ctype).text(inputtext)
                        hideActionSheet()
                    } else {
                        layer.msg(res.errmsg);
                    }
                }
            });
        }
    </script>

</body></html>